package com.depthsdata.coe.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import com.depthsdata.coe.dao.BusinessNodeFormDAOQueryBean;
import com.depthsdata.coe.service.BusinessNodeFormBean;
import com.depthsdata.coe.service.IBusinessNodeService;
import com.ourteam.frame.controller.AbstractCRUDServiceController;

@Controller
@CrossOrigin
@RequestMapping("/api/COE/businessNodeForm")
public class BusinessNodeFormManageAPI extends
		AbstractCRUDServiceController<BusinessNodeFormDAOQueryBean, BusinessNodeFormSearchBean, BusinessNodeFormBean> {

	@Autowired
	private IBusinessNodeService businessNodeService;

	@Override
	protected BusinessNodeFormDAOQueryBean newQueryBean() {
		return new BusinessNodeFormDAOQueryBean();
	}

	@Override
	protected int queryCount(BusinessNodeFormDAOQueryBean queryBean) throws Exception {
		return businessNodeService.queryBusinessNodeFormCount(queryBean);
	}

	@Override
	protected BusinessNodeFormBean[] queryData(BusinessNodeFormDAOQueryBean queryBean) throws Exception {
		return businessNodeService.queryBusinessNodeForms(queryBean);
	}

	@Override
	protected void deleteData(long[] ids) throws Exception {

		businessNodeService.deleteBusinessNodeForms(ids);

	}

	@Override
	protected BusinessNodeFormBean getDataById(long id) throws Exception {
		return businessNodeService.getBusinessNodeFormById(id);
	}

	@Override
	protected void saveData(BusinessNodeFormBean dataBean) throws Exception {

		if (dataBean.getId() == 0) {
			businessNodeService.addNewBusinessNodeForm(dataBean);
		} else {
			businessNodeService.modifyBusinessNodeForm(dataBean);
		}

	}

}
